#!/usr/bin/python3.8
# -*- coding=UTF-8 -*-
"""
@author=    lizhiheng
@date=      2022/3/9
@software=  PyCharm
@file=      add_pingtai.py
@project=   tender_project
@time=      9=26
@user=      Administrator
"""


import pymysql

conn = pymysql.connect(host='101.35.198.253',port=3306,user='liyang',password= 'liyang',database= 'liyang',charset= 'utf8')
curosr = conn.cursor()

tables = {'安徽省招标投标信息网': { 'db_name': 'lizhiheng',  'col_name': 'anhui_zhaobiaotoubiao', 'url': 'http://www.ahtba.org.cn/',"model":"Anhui_Statis"},
         '内蒙古自治区公共资源交易网': { 'db_name': 'lizhiheng',  'col_name': 'quanguo_neimenggu', 'url': 'http://ggzyjy.nmg.gov.cn/',"model":"NMG_Statis"},
          '福建省公共资源交易网': { 'db_name': 'lizhiheng',  'col_name': 'fujiangonggongziyuan', 'url': 'https://fjggzyjy.cn/',"model":"Fujian_Statis"},
          '全国公共资源交易平台（天津市）': { 'db_name': 'lizhiheng',  'col_name': 'quanguo_tianjin', 'url': 'http://ggzy.zwfwb.tj.gov.cn/',"model":"TianJIn_Statis"},
          '全国公共资源交易平台（山西省）': { 'db_name': 'lizhiheng',  'col_name': 'quanguo_shanxi', 'url': 'http://prec.sxzwfw.gov.cn/',"model":"ShanXi_Statis"},
          # '内蒙古招标投标公共服务平台': { 'db_name': 'lizhiheng',  'col_name': 'neimenggu_zhaobiao_toubiao', 'url': 'http://zbgg.nmgztb.com.cn/',"model":"NMGZT_Statis"},
          '浙江省公共资源交易': { 'db_name': 'lizhiheng',  'col_name': 'zhejianggonggongziyuan', 'url': 'http://new.zmctc.com/zjgcjy/',"model":"ZheJiang_Statis"},
          '全国公共资源交易平台（河北省）': { 'db_name': 'lizhiheng',  'col_name': 'quanguo_heibeisheng', 'url': 'http://ggzy.hebei.gov.cn/index.html',"model":"HeBei_Statis"},
          '全国公共资源交易平台（上海市）': { 'db_name': 'lizhiheng',  'col_name': 'quanguo_shanghai', 'url': 'https://www.shggzy.com/',"model":"ShangHai_Statis"},
          '全国公共资源交易平台（江苏省）': { 'db_name': 'lizhiheng',  'col_name': 'quanguo_jiangsusheng2', 'url': 'http://jsggzy.jszwfw.gov.cn/jyxx/tradeInfonew.html',"model":"Jiangsu_Statis"},
          '浙江政府采购网': { 'db_name': 'lizhiheng',  'col_name': 'zhejiangzhengfucaigou', 'url': 'https://zfcg.czt.zj.gov.cn/',"model":"ZheJiangCaiGou_Statis"},
          '全国公共资源交易平台（北京市）': { 'db_name': 'lizhiheng',  'col_name': 'quanguo_beijing2', 'url': 'https://ggzyfw.beijing.gov.cn/',"model":"BJ_Statis"},
          '福建招标与采购网': { 'db_name': 'lizhiheng',  'col_name': 'fujiangonggongdianzi_history2', 'url': 'https://ggzyfw.fujian.gov.cn/web/index.html#/index/new',"model":"FujianDianZiLiShi_Statis"},
          '广州公共资源交易中心': { 'db_name': 'lizhiheng',  'col_name': 'guangzhou', 'url': 'http://www.gzggzy.cn/',"model":"GuangZhou_Statis"},
          '福建省公共资源交易电子公共服务平台': { 'db_name': 'lizhiheng',  'col_name': 'fujiangonggongdianzi2', 'url': 'https://ggzyfw.fujian.gov.cn/web/index.html#/index/new',"model":"FuJianDianZi_Statis"},
          '北京工程建设交易信息网': { 'db_name': 'lizhiheng',  'col_name': 'beijinggongcheng3', 'url': 'http://www.bcactc.com/',"model":"BeiJingGongCheng_Statis"},
          # '广西壮族自治区招标投标': { 'db_name': 'lizhiheng',  'col_name': 'guangxi_zhaobiao_toubiao', 'url': 'http://zbtb.gxi.gov.cn:9000/',"model":"GuangxiZT_Statis"},
          "全国公共资源交易平台（海南省）":{'db_name': 'lizhiheng',  'col_name': 'quanguo_hainan', 'url': 'http://zw.hainan.gov.cn/ggzy/',"model":"HaiNan_Statis"},
          "海南省政府采购":{'db_name': 'lizhiheng_db2',  'col_name': 'hainanzhengfucaigou', 'url': 'http://zw.hainan.gov.cn/ggzy/',"model":"HaiNanZF_Statis"},
          "贵州省公共资源交易云":{'db_name': 'lizhiheng_db2',  'col_name': 'quanguo_guizhou', 'url': 'https://ggzy.guizhou.gov.cn/jyxx/',"model":"GuiZhou_Statis"},
          "重庆市公共资源交易网_重庆市公共资源交易中心":{'db_name': 'lizhiheng_db2',  'col_name': 'quanguo_chongqing', 'url': 'https://www.cqggzy.com/jyxx/transaction_detail.html',"model":"ChongQing_Statis"},
          "西藏公共资源交易平台":{'db_name': 'lizhiheng_db2',  'col_name': 'quanguo_xizang', 'url': 'http://ggzy.xizang.gov.cn/',"model":"XiZang_Statis"},
          "全国公共资源交易平台（陕西省）陕西省公共资源交易中心":{'db_name': 'lizhiheng_db2',  'col_name': 'quanguo_shanxi2', 'url': 'http://www.sxggzyjy.cn/',"model":"Shanxi2_Statis"},
          "青海公共资源交易网":{'db_name': 'lizhiheng_db2',  'col_name': 'quanguo_qinghai', 'url': 'http://www.qhggzyjy.gov.cn/ggzy/',"model":"QingHai_Statis"},
          "宁夏回族自治区政府采购网":{'db_name': 'lizhiheng_db2',  'col_name': 'ningxiacaigou', 'url': 'http://www.ccgp-ningxia.gov.cn/public/NXGPPNEW/dynamic/contents/CGGG/index.jsp?cid=312&sid=1',"model":"Ningxia_Statis"},
          "河南省电子招标投标公共服务平台":{'db_name': 'lizhiheng_db2',  'col_name': 'henandianzi', 'url': 'http://hndzzbtb.hndrc.gov.cn/',"model":"Henandianzi"},
          "河北招投标公共服务平台":{'db_name': 'lizhiheng_db2',  'col_name': 'hebeizhaobiaotoubiao', 'url': 'http://www.hebeieb.com/',"model":"Hebeizhaobiaotoubiao"},
          "山西招投标公共服务平台":{'db_name': 'lizhiheng_db2',  'col_name': 'shanxizhaobiaotoubiao', 'url': 'http://www.sxbid.com.cn/',"model":"Shanxizhaobiaotoubiao"},
          "江苏省招标投标公共服务平台":{'db_name': 'lizhiheng_db2',  'col_name': 'jiangsuzhaobiaotoubiao', 'url': 'https://www.jszbtb.com/#/',"model":"Jiangsuzhaobiaotoubiao"},
          "安徽公共资源交易集团":{'db_name': 'lizhiheng_db2',  'col_name': 'anhuigonggongziyuanjituan', 'url': 'http://www.ahggzyjt.com/',"model":"Anhuigonggongziyuanjituan"},
          "江西招投标网":{'db_name': 'lizhiheng_db2',  'col_name': 'jiangxizhaobiaotoubiao', 'url': 'http://www.jxtb.org.cn/',"model":"Jiangxizhaobiaotoubiao"},
          "广西住房和城乡建设系统招投标信息网":{'db_name': 'lizhiheng_db2',  'col_name': 'guangxizhufanghejianzhuzhaobiaotoubiao', 'url': 'http://jsgl.zfcxjw.cq.gov.cn:6087/webcqjgNew/Index.aspx',"model":"Guangxizhufanghejianzhuzhaobiaotoubiao"},
          "新疆建设工程信息网":{'db_name': 'lizhiheng_db2',  'col_name': 'xinjiangjianshegongcheng', 'url': 'http://ztb.xjjs.gov.cn/xjweb/',"model":"XinJiang_Statis"},
          "辽宁政府采购网":{'db_name': 'lizhiheng_db2',  'col_name': 'liaoningzhengfucaigou', 'url': 'http://www.ccgp-liaoning.gov.cn/portalindex.do?method=goIndex',"model":"LiaoNingCaiGou"},
          "辽宁建设工程信息网":{'db_name': 'lizhiheng_db2',  'col_name': 'liaoning_jianshe_gongcheng', 'url': 'http://jgpt.lnzb.cn/',"model":"LiaoNingJiansheGongcheng"},
          "辽宁省工程招标投标信息网":{'db_name': 'lizhiheng_db2',  'col_name': 'liaoning_gongcheng_jianshe', 'url': 'http://www.lnzxzb.cn/',"model":"LiaoNingGongchengJianshe"},
          "吉林省公共资源交易平台":{'db_name': 'lizhiheng_db2',  'col_name': 'jilingonggongziyuan', 'url': 'http://www.jl.gov.cn/ggzy/',"model":"JiLinGongGongZiYuan"},
          "全国公共资源交易平台(黑龙江省)":{'db_name': 'lizhiheng_db2',  'col_name': 'heilongjiang', 'url': 'http://www.hljggzyjyw.org.cn/',"model":"HeiLongJiang"},
          "全国公共资源交易平台(辽宁省)":{'db_name': 'lizhiheng_db2',  'col_name': 'quanguo_liaoning', 'url': 'http://www.lnggzy.gov.cn/lnggzy/',"model":"LiaoNing"},
          "全国公共资源交易平台(山西省·运城市)":{'db_name': 'lizhiheng_db2',  'col_name': 'quanguo_shanxi_yuncheng', 'url': 'https://ggzyjyzx.yuncheng.gov.cn/',"model":"Yuncheng"},
          "全国公共资源交易平台(山西省·晋城市)":{'db_name': 'lizhiheng_db2',  'col_name': 'quanguo_shanxi_jincheng', 'url': 'https://www.jcggzyfw.cn/',"model":"Jincheng"},
          "全国公共资源交易平台(山西省·临汾市)":{'db_name': 'lizhiheng',  'col_name': 'quanguo_shanxi_linfen', 'url': 'http://lfggzyjy.gov.cn/cmsController.do?goPage&page=index',"model":"Linfen"},
          "上海市建设工程交易服务中心":{'db_name': 'lizhiheng_db2',  'col_name': 'shanghaijianshegongcheng', 'url': 'http://www.shcpe.cn/jyfw/index.html',"model":"ShangHaiJianShe"},
          }
sql = "insert into z_wait_parse_table (table_name,platform,binding,createdate) values(%s,%s,%s,%s)"
sql2 = "insert into z_wait_parse_table_2 (table_name,platform,binding,createdate) values(%s,%s,%s,%s)"
for k,v in tables.items():
    print(k)
    if v.get("db_name") == "lizhiheng":
        result = curosr.execute("select id from z_wait_parse_table where platform = %s",(k,))
        if not result:
            curosr.execute(sql,(v.get("col_name"),k,"lizhiheng","2021-12-01",))
            conn.commit()
    else:
        result = curosr.execute("select id from z_wait_parse_table_2 where platform = %s",(k,))
        if not result:
            curosr.execute(sql2,(v.get("col_name"),k,"lizhiheng","2021-12-01",))
            conn.commit()

curosr.close()
conn.close()